package com.yanqu.road.server.cmd.activity.civil;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.ActivityCivilRewardModule;
import com.yanqu.road.server.protocol.Protocol;

import java.util.HashSet;
import java.util.Set;

@Cmd(code = Protocol.S_ACTIVITY_GET_CIVIL_REWARD_STATUS, desc = "活动通用-获取通用全民奖励领取状态")
@CmdApi(reqMsg = ActivityProto.ActivityGetCivilRewardStatusReqMsg.class, respMsg = ActivityProto.ActivityGetCivilRewardStatusRespMsg.class)
public class ActivityGetCivilRewardStatusCmd extends AbstractCommand {

    private int activityId;

    private long activityUserId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ActivityProto.ActivityGetCivilRewardStatusReqMsg reqMsg = ActivityProto.ActivityGetCivilRewardStatusReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        activityUserId = reqMsg.getActivityUserId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        Set<Integer> conditionIds = player.getModule(ActivityCivilRewardModule.class).getReceivedCivilRewardConditions(activityId, activityUserId);
        ActivityProto.ActivityGetCivilRewardStatusRespMsg.Builder respMsg = ActivityProto.ActivityGetCivilRewardStatusRespMsg.newBuilder();
        respMsg.setRet(0);
        respMsg.addAllConditionIds(conditionIds);
        player.sendPacket(Protocol.U_ACTIVITY_GET_CIVIL_REWARD_STATUS, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
